{include="header"}

<script type="text/javascript">
   function delete_almacen(url)
   {
      if( confirm("¿Realmente desea eliminar este almacén?") )
         window.location.href = url;
   }
   $(document).ready(function() {
      $("#b_nuevo_almacen").click(function(event) {
         event.preventDefault();
         $("#modal_nuevo_almacen").modal('show');
         document.f_nuevo_almacen.scodalmacen.focus();
      });
   });
</script>

{loop="$fsc->almacen->all()"}
<form class="form" role="form" action="{$fsc->url()}" method="post">
   <input type="hidden" name="scodalmacen" value="{$value->codalmacen}"/>
   <div class="panel panel-default" style="margin: 5px;">
      <div class="panel-heading">
         <h3 class="panel-title">Código: {$value->codalmacen}</h3>
      </div>
      <div class="panel-body">
         <div class="container-fluid">
            <div class="row">
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     Nombre:
                     <input class="form-control" type="text" name="snombre" value="{$value->nombre}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     <a href="{$fsc->pais->url()}">País</a>
                     <select name="scodpais" class="form-control">
                        {loop="$fsc->pais->all()"}
                        <option value="{$value2->codpais}"{if="$value1->codpais==$value2->codpais OR $value2->codpais==$fsc->empresa->codpais"} selected="selected"{/if}>{$value2->nombre}</option>
                        {/loop}
                     </select>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     <span class="text-capitalize">{#FS_PROVINCIA#}</span>:
                     <input class="form-control" type="text" name="sprovincia" value="{$value->provincia}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     Ciudad:
                     <input class="form-control" type="text" name="spoblacion" value="{$value->poblacion}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-6 col-md-6 col-sm-6">
                  <div class="form-group">
                     Dirección:
                     <input class="form-control" type="text" name="sdireccion" value="{$value->direccion}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     Código Postal:
                     <input class="form-control" type="text" name="scodpostal" value="{$value->codpostal}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     Teléfono:
                     <input class="form-control" type="text" name="stelefono" value="{$value->telefono}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     Fax:
                     <input class="form-control" type="text" name="sfax" value="{$value->fax}" autocomplete="off"/>
                  </div>
               </div>
               <div class="col-lg-3 col-md-3 col-sm-3">
                  <div class="form-group">
                     Contacto:
                     <input class="form-control" type="text" name="scontacto" value="{$value->contacto}" autocomplete="off"/>
                  </div>
               </div>
            </div>
         </div>
      </div>
      <div class="panel-footer">
         <a class="btn btn-sm btn-danger" onclick="delete_almacen('{$fsc->url()}&delete={$value->codalmacen}')">
            <span class="glyphicon glyphicon-trash"></span> &nbsp; Eliminar
         </a>
         <button class="btn btn-sm btn-primary pull-right" type="submit" onclick="this.disabled=true;this.form.submit();">
            <span class="glyphicon glyphicon-floppy-disk"></span> &nbsp; Guardar
         </button>
      </div>
   </div>
</form>
{/loop}

<div class="modal" id="modal_nuevo_almacen">
   <div class="modal-dialog">
      <div class="modal-content">
         <form name="f_nuevo_almacen" action="{$fsc->url()}" method="post" class="form-horizontal" role="form">
            <div class="modal-header">
               <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
               <h4 class="modal-title">Nuevo almacén</h4>
            </div>
            <div class="modal-body">
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Código:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="scodalmacen" autocomplete="off"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Nombre:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="snombre" autocomplete="off"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">
                     <a href="{$fsc->pais->url()}">País</a>:
                  </label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <select name="scodpais" class="form-control col-lg-10 col-md-10 col-sm-10">
                        {loop="$fsc->pais->all()"}
                        <option value="{$value->codpais}"{if condition="$value->is_default()"} selected="selected"{/if}>{$value->nombre}</option>
                        {/loop}
                     </select>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label text-capitalize">{#FS_PROVINCIA#}:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="sprovincia" autocomplete="off" value="{$fsc->empresa->provincia}"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Ciudad:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="spoblacion" autocomplete="off" value="{$fsc->empresa->ciudad}"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Dirección:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="sdireccion" autocomplete="off"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Código Postal:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="scodpostal" autocomplete="off" value="{$fsc->empresa->codpostal}"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Teléfono:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="stelefono" autocomplete="off"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Fax:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="sfax" autocomplete="off"/>
                  </div>
               </div>
               <div class="form-group">
                  <label class="col-lg-2 col-md-2 col-sm-2 control-label">Contacto:</label>
                  <div class="col-lg-10 col-md-10 col-sm-10">
                     <input class="form-control" type="text" name="scontacto" autocomplete="off"/>
                  </div>
               </div>
            </div>
            <div class="modal-footer">
               <button class="btn btn-sm btn-primary" type="submit" onclick="this.disabled=true;this.form.submit();">
                  <span class="glyphicon glyphicon-floppy-disk"></span> &nbsp; Guardar
              </button>
            </div>
         </form>
      </div>
   </div>
</div>

{include="footer"}